package com.xt.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class StudentDao  {
    private static StudentDao dao=new StudentDao();
    public  StudentDao() {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (Exception e) {
            // TODO: handle exception
            JOptionPane.showMessageDialog(null, "数据库加载失败"+e.getMessage());
        }
    }
    public static Connection getConn()
    {
        try {
            Connection conn=null;
            String url="jdbc:mysql://localhost:3306/stugui?&characterEncoding=utf-8&serverTimezone=UTC";   //127.0.0.1:3306
            conn=DriverManager.getConnection(url,"root","6235290");
            return conn;
        } catch (Exception e) {
            // TODO: handle exception
            JOptionPane.showMessageDialog(null, "数据库连接失败"+e.getMessage());
            return null;
        }
    }
}
